package com.emokili.ewa.app.config;

import com.emokili.ewa.app.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

//注册拦截器
@Configuration
public class AppConfig  extends WebMvcConfigurerAdapter {
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        //注册自己的拦截器并设置拦截的请求路径
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
        .excludePathPatterns("/login")
        .excludePathPatterns("/register")
        .excludePathPatterns("/recaptcha");
        super.addInterceptors(registry);
    }
}
